<?php
namespace app\app\controller\v1;

use think\Db;
use think\Request;
use app\app\util\OnlineUtils;

class PvController extends BaseController{

    /**
     * 显示资源列表
     * 浏览列表
     * @return \think\Response
     */
    public function index()
    {
        $user_id = OnlineUtils::getUserIdBySid();
        if(input('get.id') && input('get.id') >0){
            $page = config('PAGE_NUM').input('get.id');
        }else{
            $page = 0;
        }
        $pv = Db::query('select a.id,a.user_id,b.username,b.portrait,c.id,c.name,c.position,c.company_name from hmp_pv a left join hmp_users b on a.user_id=b.id left join hmp_card c on a.card_id=c.id where a.pv_user_id='.$user_id.' and b.status=1 order by a.id desc limit '.$page.',10');
        if($pv){

        }else{
            $pv = [];
        }
        return hmp(200,'success',['data'=>$pv]);
    }

    /**
     * [getMypvList 我的点赞]
     * @return [type] [description]
     */
    public function getMyPvList()
    {
        $user_id = OnlineUtils::getUserIdBySid();
        if(input('get.id') && input('get.id') >0){
            $page = config('PAGE_NUM').input('get.id');
        }else{
            $page = 0;
        }
        $pv = Db::query('select a.id,a.pv_user_id as user_id,b.username,b.portrait,c.id,c.name,c.position,c.company_name from hmp_pv a left join hmp_users b on a.pv_user_id=b.id left join hmp_card c on a.card_id=c.id where a.user_id='.$user_id.' and b.status=1 order by a.id desc limit '.$page.',10');
        if($pv){

        }else{
            $pv = [];
        }
        return hmp(200,'success',['data'=>$pv]);        
    }

    /**
     * 显示创建资源表单页.
     *
     * @return \think\Response
     */
    public function create()
    {

    }

    /**
     * 保存新建的资源
     * 点赞
     * @param  \think\Request  $request
     * @return \think\Response
     */
    public function save()
    {
    	return hmp_json(200,'success');
    }

    /**
     * 显示指定的资源
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function read($id)
    {

    }

    /**
     * 显示编辑资源表单页.
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * 保存更新的资源
     *
     * @param  \think\Request  $request
     * @param  int  $id
     * @return \think\Response
     */
    public function update($id)
    {

    }

    /**
     * 删除指定资源
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function delete($id)
    {

    }
}